// 1. 定义状态容器
// 2. 创建容器中的state
// 3. 仓库中的action的使用

import {defineStore} from 'pinia'
import { ChengStore } from './Cheng'


export const mainstore = defineStore('main', {
    state: () => {
        return {
            helloWorld: ' Hello World',
            count: 0,
            phone: 18720725416
        }
    },
    getters: { // 有缓存特性
        phoneHidden(state) {
            console.log('Getters');
            
            return state.phone.toString().replace(/^(\d{3})\d{4}(\d{4})$/,'$1****$2')
        }
    },
    actions: {
        changeState() {
            this.count++
            this.helloWorld = 'cheng'
        },
        getList() {
            console.log(ChengStore().list);
            
        }
    }
})
